import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import router from  './router'
import './css/global.css'
import axios from 'axios'
import './assets/fonts/iconfont.css'
import TreeTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor);
Vue.component('tree-table',TreeTable);

Vue.config.productionTip = false;
Vue.use(ElementUI);
Vue.prototype.$http=axios;
axios.defaults.baseURL='http://127.0.0.1:8888/api/private/v1/';  // 配置请求根路径。
axios.interceptors.request.use(config=>{
  config.headers.Authorization=window.sessionStorage.getItem('token');
  return config;
});

Vue.filter('dataFormat',function (originVal) {
  const dt=new Date(originVal);

  const year=dt.getFullYear();
  const month=(dt.getMonth()+1+'').padStart(2,'0');  // 如果不足两位，用0填充
  const day = (dt.getDate()+'').padStart(2,'0');
  const hour = (dt.getHours()+'').padStart(2,'0');
  const minute = (dt.getMinutes()+'').padStart(2,'0');
  const second = (dt.getSeconds()+'').padStart(2,'0');
  return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
});

new Vue({
  render: h => h(App),
  router:router
}).$mount('#app');
